df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
filter(drug != "altered contexts") %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# compare with p-WT (baseline)
MIfreq$genotype <- factor(MIfreq$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug * genotype  + (1|animal_ID) + (1|expt_date)") + ylim(-0.25, 0.25)
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-i-KO')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug != 'altered contexts')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
filter(drug != "altered contexts") %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# compare with p-WT (baseline)
MIfreq$genotype <- factor(MIfreq$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ drug * genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ drug * genotype  + (1|animal_ID) + (1|expt_date)") + ylim(-0.25, 0.25)
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# Perform LMEM statistics on pMI and MI data (place cell proportions)
# specify directory to the data file (excel/csv)
# change to match your local machine
MI_and_pMI <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/MI_and_pMI.xlsx")
# get data and filter for only first session (day1/AM)
# filter out data where mobility is below a certain threshold
MIfreq <- MI_and_pMI
MI_data_AM_day1_only <- MIfreq %>%
filter(expt_time == "day1" | expt_time == "AM") %>%
filter(Mobility_Pass == 1) %>%
filter(drug == 'saline')
# filter out data that you don't need for place cell statistics
MIfreq <- MI_data_AM_day1_only %>%
nest_by(session,genotype,animal_ID,drug,expt_date,.keep=TRUE) %>%
dplyr::select(session,genotype,animal_ID,drug,expt_date)
# compare with p-WT (baseline)
MIfreq$genotype <- factor(MIfreq$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# adjust the levels of data & set the baseline (saline) for comparison
MIfreq$drug <- factor(MIfreq$drug, levels = c("saline"))
# avoid bugs
MIfreq <- MIfreq %>%
group_by(genotype) %>%
add_column(lowMIfreq = 0) # add empty column to fill in later with frequencies
# p-value is set as variable lowMI
lowMI = 0.05
numRowsTable = NROW(MIfreq)
for (i in 1:numRowsTable){
df <- MI_data_AM_day1_only %>%
filter(session == as.character(MIfreq[i,1]))
freq = NROW(filter(df, MI_p_values<lowMI)) / NROW(df)
MIfreq[i,6]=freq
}
# make table of average values of pMI by animal_ID under each condition
pMItable <- aggregate(lowMIfreq ~ genotype:animal_ID:drug, data = MIfreq, mean,
simplify = TRUE)
#################################################################
# test for interaction in mixed effects model
MI.model= lmer (lowMIfreq ~ genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=FALSE)
anova(
MI.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# generate figs
MI.model= lmer(lowMIfreq ~ genotype + (1|animal_ID) + (1|expt_date), data=MIfreq, REML=TRUE)
par(mfrow=c(1,3))
plot(residuals(MI.model),las=1, ylim=c(-2,2))
hist(residuals(MI.model),las=1)
qqnorm(residuals(MI.model),las=1)
qqline(residuals(MI.model), col = "red", lwd=2)
coef(MI.model)
summary(MI.model)
sjPlot::plot_model(MI.model, title = "MI ~ genotype  + (1|animal_ID) + (1|expt_date)")
sjPlot:: tab_model(MI.model, title = "MI ~  (1|animal_ID) + (1|expt_date)")
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on animal's mobility
RMvalues <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts')
# compare with p-WT (baseline)
RMvalues$genotype <- factor(RMvalues$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
RMvalues$drug <- factor(RMvalues$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)") + ylim(-0.5, 0.5)
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'p-WT')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-pyr-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts') %>%
filter(genotype == 'a5-i-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on animal's mobility
RMvalues <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug != 'altered contexts')
# compare with p-WT (baseline)
RMvalues$genotype <- factor(RMvalues$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
RMvalues$drug <- factor(RMvalues$drug, levels = c("saline", "etomidate 2mg/kg", "etomidate 4mg/kg", "etomidate 6mg/kg", "etomidate 7mg/kg", "etomidate 8mg/kg"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RMvalues, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)") + ylim(-0.5, 0.5)
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell:animal_ID)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')%>%
filter(genotype == 'p-WT')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')%>%
filter(genotype == 'a5-i-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')%>%
filter(genotype == 'a5-pyr-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')%>%
filter(genotype == 'a5-pyr-KO')
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date)  + (1|cell_ID:animal_ID), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID)")
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
# linear mixed model statistics for RM correlations
# load data
RM_correlation <- read_excel("D:/Meta_AnaOutput_Graphs/Zhu 2022 GAD paper (combined p-WTs)/RM_correlation.xlsx")
# filter out data based on mobility of the animal
RM_values <- RM_correlation %>%
filter(session1_mobility_pass == 1 & session2_mobility_pass == 1) %>%
filter(drug == 'saline' | drug == 'altered contexts')
# compare with p-WT (baseline)
RM_values$genotype <- factor(RM_values$genotype, levels = c("p-WT", "a5-i-KO", 'a5-pyr-KO'))
# make sure you compare with saline baseline
RM_values$drug <- factor(RM_values$drug, levels = c("saline", "altered contexts"))
# test using LMEM & ANOVA
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RM_values, REML=FALSE)
anova(
RM_values.model,
type = c("III", "II", "I", "3", "2", "1"),
ddf = c("Satterthwaite", "Kenward-Roger", "lme4"))
# perform some plotting
par(mfrow=c(1,3))
RM_values.model= lmer (RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID), data=RM_values, REML=TRUE)
plot(residuals(RM_values.model),las=1, ylim=c(-2,2))
hist(residuals(RM_values.model),las=1)
qqnorm(residuals(RM_values.model),las=1)
qqline(residuals(RM_values.model), col = "red", lwd=2)
summary(RM_values.model)
sjPlot::plot_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID)") + ylim(-0.3,0.3)
sjPlot:: tab_model(RM_values.model, title = "RM_values ~ drug * genotype + (1|animal_ID) + (1|animal_ID:expt_date) + (1|cell_ID:animal_ID)",
auto.label = TRUE, show.stat = TRUE, show.df = TRUE, show.se = TRUE)
